package com.eascs.message.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import com.eascs.admin.common.controller.BaseMasterViewController;
import com.eascs.app.dao.PageResult;
import com.eascs.common.util.StringUtil;
import com.eascs.message.form.O2oMessageForm;
import com.eascs.message.service.impl.O2oMessageServiceImpl;
import com.eascs.site.page.PaginationInfo;
import com.eascs.site.page.SelectDataOption;
import com.eascs.site.view.BaseRestResult;
import com.eascs.site.view.ViewContext;



@Controller
@RequestMapping("/message")
public class O2oMessageController extends BaseMasterViewController  { 

	
	@Autowired
	O2oMessageServiceImpl o2oMessageServiceImpl;
	
	@SuppressWarnings("unused")
	@RequestMapping("/o2omessage_list")
	public String loanList(O2oMessageForm o2oMessageForm){
		o2oMessageForm.setPageSize(10);
		PageResult<Object[]> pageResult= o2oMessageServiceImpl.messageList(o2oMessageForm);
		String[] titles = {"主键id","贷款单号" ,"借款姓名","电话号码","短信内容","创建时间", "短信类型", "平台"};
		String pageUrl="/message/o2omessage_list";
		String findCondition="";
		if(o2oMessageForm!=null){
			String loanapplyno = !StringUtil.isNotBlank(o2oMessageForm.getLoanapplyno())?"":o2oMessageForm.getLoanapplyno();
			String receiveName = !StringUtil.isNotBlank(o2oMessageForm.getReceiveName())?"":o2oMessageForm.getReceiveName();
			String messageType = !StringUtil.isNotBlank(o2oMessageForm.getMessageType())?"":o2oMessageForm.getMessageType();
			String platformType = !StringUtil.isNotBlank(o2oMessageForm.getPlatformType())?"":o2oMessageForm.getPlatformType();
			findCondition="?loanapplyno="+loanapplyno+"&receiveName="+receiveName+"&messageType="+messageType+"&platformType="+platformType;
			pageUrl=pageUrl+findCondition+"&showPage=";
		}else{
			pageUrl=pageUrl+"?showPage=";
		}
		SelectDataOption[] selectDataOptions = {null, null, null, null, null,null,
				new SelectDataOption("MESSAGE_TYPE"), new SelectDataOption("MESSAGE_PLATFORM_TYPE") };
		PaginationInfo paginationInfo = new PaginationInfo(pageResult, titles, pageUrl);
		paginationInfo.setSelectDataOptions(selectDataOptions);
		paginationInfo.setBuildPagingNavigation(true);
		paginationInfo.setFirstRenderColumnIndex(0);
	/*	AjaxButton[] dealButton=new AjaxButton[]{new AjaxButton("删除", "/bank/del_loan?billCode=")};
		paginationInfo.setMoreButtons(dealButton);*/
		ViewContext.put("paginationInfo", paginationInfo);
		ViewContext.put("vo", o2oMessageForm);
		BaseRestResult.refresh();
		//return "/bank/loan_list";
		return "/message/message_list";
	}
	
	/*@RequestMapping("/sendMessage")
	public void test(String billCode){
		o2oMessageServiceImpl.nsEndMessage(billCode);
	}*/
	
}
